/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.uet.model;

import java.util.List;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import sentencesplit.SentenceSplit;
/**
 *
 * @author thinhnk
 */
public class Post {
    int id;//specify Post in a thread
    //target
    public int score;
    //properties
    public String user;
    public int thanks;
    public int fblikes;
    public List<String> sentences;   
    //Specify the post contain quotaion or not
    public boolean quotation;    
    
    public Post(int _id, Element post){
        id = _id;
        String scoreStr = post.getAttribute("score");
        if(scoreStr.length() != 0){
            score = Integer.valueOf(scoreStr);
        }else{
            score = 0;
        }
        user = post.getElementsByTagName("user").item(0).getTextContent();
        String thankStr = post.getElementsByTagName("thanks").item(0).getTextContent();
        if(thankStr.length() != 0){
            thanks = Integer.valueOf(thankStr);
        }else{
            thanks = 0;
        }
        String text = post.getElementsByTagName("text").item(1).getTextContent();
        sentences = SentenceSplit.split(text);
    }
    public String toString(){
        StringBuilder s = new StringBuilder();
        s.append("START: Normal Post\n");
        s.append("ID = ").append(id);
        s.append(" Score = ").append(score);
        s.append(" User = ").append(user);
        s.append(" Thank = ").append(thanks);
        s.append(" NUM_OF_SENS = ").append(sentences.size()).append("\n");
        for(String sen: sentences){
            s.append(sen).append("\n");
        }
        s.append("END");
        return s.toString();               
    }
}
